Rounding and billing fix#90
Merged
Merged
Conversation
Collaborator
✅ Heimdall Review Status
|
ilikesymmetry
left a comment
Collaborator
There was a problem hiding this comment.
Did not review tests, but looks like a relatively simple modification. Good principle learned: prefer custom net-amount args as calldata with math + checks against constraints versus passing in fields that derive the net-amount and restrict rounding preferences.
amiecorso
reviewed
Jun 24, 2026
amiecorso
reviewed
Jun 24, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
RuoHan-Chen
force-pushed
the
roundingAndBillingFix-contract-only
branch
from
July 15, 2026 23:13
45b0c67 to
b6e1478
Compare
Add happy-path tests for feeAmount at the min/max bps-derived bounds and for minFee=maxFee=0, a cent-aligned fee happy path for charge() (mirroring capture's), and fuzz tests over feeAmount for both capture and charge. Also rename test_charge_reverts_whenFeeAmountAboveMax to test_reverts_whenFeeAmountAboveMax for naming consistency.
Complements the existing zero-fee happy path with the deterministic revert case at the same boundary, since the fuzzed above-max test only hits minFeeBps=maxFeeBps=0 probabilistically.
stevieraykatz
approved these changes
Jul 16, 2026
ilikesymmetry
approved these changes
Jul 16, 2026
| env: | ||
| FOUNDRY_PROFILE: ci | ||
| BASE_RPC_URL: "https://mainnet.base.org" | ||
| BASE_RPC_URL: "https://base.publicnode.com" |
Collaborator
There was a problem hiding this comment.
Something feels off about this. Are we getting rate limited on our own node for our CI? Can we confirm security is okay with this?
Collaborator
|
Review Error for ilikesymmetry @ 2026-07-16 17:33:35 UTC |
Collaborator
|
Think my phone OS is out of date, one sec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace basis-points-encoded fees (
feeBps) with an absolutefeeAmount(in raw token units) oncapture()andcharge(). The payer-approvedminFeeBps/maxFeeBpsonPaymentInfoare unchanged and continue to bound the fee, but they are now applied to the operator-supplied absolute amount rather than used to compute it:This lets operators pass cent-aligned fees computed off-chain without losing precision to on-chain BPS truncation, while preserving the same payer-side guarantees.
Design doc: https://docs.google.com/document/d/1RCIXH0Q46XcwyYcu3027g9bKXHljrEX-y_ciBIdGNIQ
Implementation follows the approach used in PPS.
Changes
Contracts
AuthCaptureEscrow.capture(...)andcharge(...):uint16 feeBps→uint256 feeAmount._validateFeenow takesamount+ absolutefeeAmountand checks it against the min/max bounds derived from bps._distributeTokensuses the suppliedfeeAmountdirectly (no on-chain multiplication/division).FeeBpsOutOfRange(feeBps, minFeeBps, maxFeeBps)→FeeAmountOutOfRange(feeAmount, minFee, maxFee).PaymentCharged/PaymentCapturedevents:uint16 feeBps→uint256 feeAmount.ERC3009PaymentCollector,Permit2PaymentCollector) updated to the new signature.Docs
docs/Fees.md,docs/operations/Capture.md,docs/operations/Charge.mdrewritten to describe absolute-fee semantics with worked examples and updated error list.Tooling
[profile.ci]tofoundry.toml.Testing
Tests updated across the suite to pass absolute
feeAmountvalues instead of bps:test/src/PaymentEscrow/{authorize,capture,charge,refund,reentrancy,e2eCoinbaseSmartWallet}.t.soltest/src/collectors/SpendPermissionPaymentCollector.t.soltest/gas/gasBenchmark.t.soltest/base/AuthCaptureEscrowBase.sol,test/base/AuthCaptureEscrowSmartWalletBase.solFeeAmountOutOfRangebounds cases (below-min, above-max, and both-zero) are exercised incapture.t.sol/charge.t.sol.Backwards compatibility
Breaking public ABI change:
charge(),capture(),PaymentCharged, andPaymentCapturedall change parameter/field types. Integrators must migrate before upgrading.